/*
package com.example.demo.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class TimeAspect {
    @Pointcut("execution(* com.example.demo.controller.*.*(..))")
    public void pt(){}


    @Before("pt()")
    public void doBefore(){
        log.info("执行before方法");
    }
    @After("pt()")
    public void doAfter(){
        log.info("执行After方法");

    }
    @AfterReturning("pt()")
    public void doAfterReturning(){
        log.info("执行AfterReturning方法");

    }
    @AfterThrowing("pt()")
    public void doAfterThrowing(){
        log.info("执行AfterThrowing方法");

    }
    @Around("pt()")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        log.info("Around方法开始前");
        Object object = joinPoint.proceed();
        log.info("Around方法开始后");
        return object;
    }

    @Around("pt()")
    public Object recordTime(ProceedingJoinPoint pjp) throws Throwable {
        //记录方法执行开始时间
        long begin = System.currentTimeMillis();
        //执行方法
        Object result = pjp.proceed();
        //记录执行方法结束时间
        long end = System.currentTimeMillis();
        //记录方法执行耗时
        log.info(pjp.getSignature() + "耗时: {} ms",end-begin);
        return result;
    }
}
*/
